﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace LED_Editor.Controls
{
    public class ColorDataGridViewCell:DataGridViewCell
    {
        protected override void Paint(System.Drawing.Graphics graphics, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
            Color color = (Color)value;

            if (color.A == 0)
            {
                color = Color.Black;
            }

            int borderWidth = ((ColorDataGridViewColumn)OwningColumn).BorderWidth ;

            Rectangle rect = cellBounds;
           
            TextBoxRenderer.DrawTextBox(graphics, rect, System.Windows.Forms.VisualStyles.TextBoxState.Normal);  
            using (Brush brush = new SolidBrush(color))
            {
                rect.Inflate(-1, -1 );
                graphics.FillRectangle(brush, rect);
            }
            
        }
    }
}
